from matplotlib import pyplot

import histogram

def plot_eff1d(x, y_rs, y_ws, 
               ylabel='# Events passed', 
               loc='best', 
               title='plot\_ eff1d',
               xlabel='Cut values',
               rsfmt='b2',
               wsfmt='ro',
               rslabel='RS',
               wslabel='WS',
               out='plot_eff1d.png',
               ):

    pyplot.figure(figsize=(8,6))

    pyplot.axes((0.175, 0.15, 0.8, 0.72))

    pyplot.plot(x, y_ws, wsfmt, label=wslabel)
    pyplot.plot(x, y_rs, rsfmt, label=rslabel)

    pyplot.legend(loc=loc)
    pyplot.xlabel(xlabel)
    pyplot.ylabel(ylabel)
    pyplot.title(title)
    
    pyplot.savefig(out)

    return out
            

def before_after(hf1, hf2, name,
                 labels=('All', 'Pass'),
                 fc=('#CCCCCC', 'g'),                 
                 a2='0.6',
                 title=None,
                 out=None,
                 ):

    h1 = histogram.load(hf1, name)
    h2 = histogram.load(hf2, name)

    if not title:
        title = h1.title    

    if not out:
        out = h1.name

    h1.draw(hold=True, label=labels[0], facecolor=fc[0], title=title)
    return h2.draw(name=out, same=True, label=labels[1], facecolor=fc[1], alpha=a2)

    
    
    
    
    
    
    
    
